<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/23
 * Time: 16:22
 */

namespace app\api\controller;

use app\common\model\Announcement as Model;
use app\common\controller\Api;
use think\Request;

class Announcement extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function lists()
    {
        $announcements = Model::where('switch',1)
            ->where('publishtime','<=',time())
            ->field('id,title,publishtime')
            ->order('id','desc')
            ->select();
        $this->success('成功',$announcements);
    }
    public function detail(Request $request)
    {
        $id = $request->get('id');
        $det = Model::where('switch',1)
            ->where('publishtime','<=',time())
            ->where('id',$id)
            ->field('id,title,content,publishtime')
            ->find();
        $this->success('成功',$det);
    }
}